
#ifndef BUTTON_H
#define BUTTON_H

// INCLUDES ********************************************************************

#include "Sprite.h"

#include "TouchListener.h"

#include "Function.h"

// FORWARD DECLARATIONS ********************************************************

// *****************************************************************************

//! Button
//! 
//! Basic button class for menus or use in game (pause button etc.), this is 
//! essentially a sprite using 2 textures

// *****************************************************************************

namespace Meteor 
{
    class Button : public Sprite, public Meteor::TouchListener
    {
         public:
            Button( const std::string& normalImage,
                    const std::string& altImage=0);
                    
            Button( const std::string& normalImage,
                    const std::string& altImage=0,
                    const uint32_t zIndex=0);
            
            virtual ~Button();
            
            //! a button is automatically added as a touch delegate
            virtual void TouchBegan( const Vector2D& position);
        
            virtual void TouchMoved( const Vector2D& position);
        
            virtual void TouchEnded( const Vector2D& position, double duration);
            
            //! function called when button is clicked
            void SetCallback( Function* callback);
    
        protected:
            //! display alternative image when button is touched
            Texture2D* mTextureAlt;
            
            //! pointer for current texture to be drawn
            Texture2D* mTextureOrignal;
            
            //! will store an object and a method to be
            //! used for callbacks when button is touched
            Function* mCallback;
        
    }; // end of class Button
    
} // end of namespace Meteor

#endif // BUTTON_H
